package com.ssy.lingxi.common.handler;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.ssy.lingxi.common.exception.BusinessException;
import com.ssy.lingxi.common.response.ResponseCode;
import com.ssy.lingxi.common.utils.Aes128Util;

import java.util.regex.Pattern;

public class AesDecryptDeserialize extends JsonDeserializer<String> {

    @Override
    public String deserialize(JsonParser p, DeserializationContext ctxt) {
        try {
            return Aes128Util.aesDecrypt(p.getValueAsString());
        } catch (Exception e) {
            throw new BusinessException(ResponseCode.AES_DECRYPT_ERROR);
        }
    }
}
